Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CF 2.0: Problem with DataGrid and decimal column

28 views
Skip to first unread message

Carmine Moleti

unread,
Sep 27, 2006, 4:48:58 AM9/27/06
to
Hi to everyone,

This is the very first application I'm writing in C# .Net 2.0 for a
Smart device.

I've a class which, among its properties, there's one whose type is decimal.
This class' instances are bound to a datagrid via BindingSource.
When debugging via the emulator the datagrid correctly reports the value
in the decimal property.

Deploying the application to the pocket pc (WM 5.0) everything works ok
except for the decimal column.

E.g.:

If the property has a value of 0.52, the emulator displays 0.52 (as I
expected), while on the pocketpc it displays 52!
Summing up the column values for each row in the datagrid actually
produces the sum of only the fractionary parts!

I've read over the internet that with CF 1.1 there was a problem with
decimal columns, is it true? Does this still holds true for CF 2.0?

Thanks in advance for your help.

Regards,
Carmine

Ilya Tumanov [MS]

unread,
Sep 27, 2006, 3:08:21 PM9/27/06
to
No, there are no problems like this with decimal columns. In fact, DataGrid
does not care if it's decimal or not, it simply does .ToString() to show
data, so you can try that and see which string you'll get.

--
Best regards,


Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

*** Want to find answers instantly? Here's how... ***

1. Go to
http://groups-beta.google.com/group/microsoft.public.dotnet.framework.compactframework?hl=en
2. Type your question in the text box near "Search this group" button.
3. Hit "Search this group" button.
4. Read answer(s).

"Carmine Moleti" <carmin...@askme.ask> wrote in message
news:efddnc$cbn$1...@newsread.albacom.net...

Carmine Moleti

unread,
Sep 27, 2006, 4:46:47 PM9/27/06
to
Ilya Tumanov [MS] ha scritto:

> No, there are no problems like this with decimal columns. In fact, DataGrid
> does not care if it's decimal or not, it simply does .ToString() to show
> data, so you can try that and see which string you'll get.

Ilya, you're right. I've followed your advice of dumping the property's
contents via .ToString(), and actually got the "unexpected" result.

What could it be that makes this "conversion" happens? (It works in the
emulator)

Thanks for pointing me in the right direction.

Carmine Moleti

unread,
Sep 28, 2006, 2:06:58 AM9/28/06
to
Carmine Moleti ha scritto:

Forgot to mention I've also used the "Format" property of the
DataGridTextBoxColumn.
Setting it to "c" on the emulator still produced the correct behaviour,
while on the device 0.52 is represented by "$ 52.00" !

biondo

unread,
Sep 28, 2006, 2:16:47 AM9/28/06
to
How are you loading this number...

I had similar problem when inserting numbers from ".txt" file to SQLCE...
The problem was in the regional settings - decimal symbol...

maurizo


"Carmine Moleti" <car...@askme.com> wrote in message
news:451ae339$0$47966$4faf...@reader3.news.tin.it...

Carmine Moleti

unread,
Sep 28, 2006, 3:21:29 AM9/28/06
to
Hi Maurizio,

> How are you loading this number...
>
> I had similar problem when inserting numbers from ".txt" file to SQLCE...
> The problem was in the regional settings - decimal symbol...

The datagrid is bound to a collection implemented via BindingList<Prodotto>.

When I add items to the collection, the datagrid gets populated
automatically.

I have specified "N2" as format for the datagridtextboxcolumn, and on
the device I see that "0.52" becomes "52.00"!
This _doesn't_ happen in the emulator.

Also tried to set a new CultureInfo for the colum without luck.

Thanks for your help

biondo

unread,
Sep 28, 2006, 4:09:16 AM9/28/06
to
I'm working still on VS2003 (because of CE 4.2) so I don't have the
datagridtextboxcolumn.Format property..

Try to see your data before binding to the grid to find out if it's the grid
property that changes "0.52" to "52.00" (format problem),
or this change happened before...

maurizio


"Carmine Moleti" <carmin...@askme.ask> wrote in message

news:effsva$fcv$1...@newsread.albacom.net...

Carmine Moleti

unread,
Sep 28, 2006, 4:32:10 AM9/28/06
to
> Try to see your data before binding to the grid to find out if it's the grid
> property that changes "0.52" to "52.00" (format problem),
> or this change happened before...

Step by step debug showed that the property is correctly held, both with
databinding and with unbound objects.

Totally clueless.

biondo

unread,
Sep 28, 2006, 7:23:33 AM9/28/06
to
Than it could be the format properties...

try format("0.00")

"Carmine Moleti" <carmin...@askme.ask> wrote in message

news:efg13r$gut$1...@newsread.albacom.net...

Carmine Moleti

unread,
Sep 28, 2006, 8:18:24 AM9/28/06
to
biondo ha scritto:

> Than it could be the format properties...
> try format("0.00")

I fear I don't understand.
Care to elaborate, please?

biondo

unread,
Sep 28, 2006, 8:33:32 AM9/28/06
to
In one of your post... you have written

> have specified "N2" as format for the datagridtextboxcolumn...

change N2 with "0.00"...

Or post part of your code where you define the datagridcolumns

maurizio


"Carmine Moleti" <carmin...@askme.ask> wrote in message

news:efgec4$o9p$1...@newsread.albacom.net...

Carmine Moleti

unread,
Sep 28, 2006, 9:45:11 AM9/28/06
to
>>have specified "N2" as format for the datagridtextboxcolumn...
> change N2 with "0.00"...

Ok, I'll try as soon as I'll get home. I'll let you know.

> Or post part of your code where you define the datagridcolumns

It's automatically generated by IDE!

Carmine Moleti

unread,
Sep 29, 2006, 12:59:07 AM9/29/06
to
Carmine Moleti ha scritto:

>>> have specified "N2" as format for the datagridtextboxcolumn...
>> change N2 with "0.00"...

No luck :(
It keeps showing data the wrong way.

Further and deeper investigation with debug on the device showed that,
most likely, it has nothing to do with format.

Decimal data is "automatically" converted the wrong way upon creation of
the objects of the collection.

So, the "drama" has finally come to an end :)

The culprit do have something to do with CulturInfo.
In the XML I have encoded decimal values as "0.52", I tried to encode
them as "0,52" and everything works properly.

Thanks a lot for your precious help, and for your patience.

0 new messages